// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  try {
    return await db.collection('moments').add({
      data: {
        open_id: event.open_id,
        nickname: event.nickname,
        images: event.images,
        avatar: event.avatar,
        content: event.content,
        _updateTime: event._updateTime,
        _createTime: event._createTime
      }
    })
  }catch(e)
  {
    console.log(e)
  }
}